package com.blb.goods_service.service;

import com.blb.goods_service.entity.Goods;
import com.blb.goods_service.util.MockData;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class GoodsService {

    @Value("${server.port}")
    private int port;

    /**
     * 通过id查找商品
     * @param id
     * @return
     */
    public Goods findGoodsById(Long id){
//        try {
//            Thread.sleep(2000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        for(Goods g : MockData.goods){
            if(id == g.getId()){
                g.setAddress("port--"+port);
                return g;
            }
        }
        return null;
    }
}
